
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>合规审核</title>
  <link rel="stylesheet" href="../../css/element.css">
	<link rel="stylesheet" href="../../css/common.css">
    
    
</head>

<body>
	<div id="app" v-cloak>
        <div id="mask" v-if="maskShow"></div>
        <el-container style="height: 100%;">


          <el-header>
            <div class="layout-logo">
                <img src="../../images/logo.png" alt="">
            </div>
            <div class="head-nav">
              <a class="active" href="javascript:void(0)">合规审核</a>
              <a href="../dataquery/complex.html">数据查询</a>
            </div>
            <div class="layout-nav font12 user_msg">
                欢迎您，{{userName}}  <a class="red" href="javascript:void(0)" @click="userQuit"> 注销 </a>
            </div>
          </el-header>

          <el-container>
           
            <!-- 右侧主视图部分 BEGIN  -->
            <el-container>

              <!-- content container begin -->
              <el-main>
                <el-card class="main-card">
  
                  <div slot="header" class="clearfix">
                    <span class="font12 gray">当前位置：合规审核</span>
                  </div>

                  <div class="input-row">

                    <span class="marR-30">
                      <span class="input-title">请输入要查询的公司代码 :</span>
                      <el-input maxlength=6 size="small" v-model='input_secuCode' class="inline-input"></el-input>
                    </span>

                    <span class="input-title">时间选择 :</span>

                      <el-date-picker
                        v-model="input_startTime"
                        type="date"
                        placeholder="选择日期时间"
                        size="small"
                        value-format="yyyy-MM-dd"
                        >
                      </el-date-picker>

                      <el-date-picker
                        v-model="input_endTime"
                        type="date"
                        placeholder="选择日期时间"
                        size="small"
                        class="marR-30"
                        value-format="yyyy-MM-dd"
                        >
                      </el-date-picker>

                      
                      <span class="input-title">审核状态 :</span>
                      <el-select v-model="selectedType" placeholder="请选择" size="small">
                        <el-option v-for="item in selectOptions" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>

                      <span class="input-title">扣分类型 :</span>
                      <el-select v-model="selectedDealType" placeholder="请选择" size="small">
                        <el-option v-for="item in dealType" :key="item" :label="item" :value="item">
                        </el-option>
                      </el-select>

                      <el-button @click="queryData(input_secuCode,input_startTime,input_endTime,selectedType,1,selectedDealType);currentPage=1" size="small">查询</el-button>

                      <el-button size="small" @click="window.location.href='./edit.html'">新增记录</el-button>
                      <el-button size="small" @click="downloadData" type="primary">导出</el-button>

                  </div>

                  <div class="table-wrap">
                    <el-table
                    :data="queryResult"
                    v-loading="loading"
                    border
                    stripe
                    style="width: 100%"
                    @selection-change="handleSelectionChange"
                    ref="multipleTable"
                    >
                    <el-table-column
                      type="selection"
                      width="40">
                    </el-table-column>
                    <el-table-column
                      prop="secu_code"
                      label="代码">
                    </el-table-column>
                    <el-table-column
                      prop="company_name"
                      label="简称">
                    </el-table-column>
                    <el-table-column
                      prop="deal_time"
                      label="时间">
                    </el-table-column>
                    <el-table-column
                      prop="deal_type"
                      label="扣分类型">
                    </el-table-column>
                    <el-table-column
                      width="400"
                      label="扣分内容">
                      <template slot-scope="scope">
                        <a :href="scope.row.deal_content_url" v-if="scope.row.deal_content_url.length" class="table-link" target="blank">{{ scope.row.deal_content }}</a>

                        <span v-if="!scope.row.deal_content_url.length" >{{ scope.row.deal_content }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="deal_score"
                      width="120"
                      label="扣分值">
                    </el-table-column>
                    <el-table-column
                    label="操作"
                    width="300">
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          @click="handleEdit(scope.row.id)">修改</el-button>
                        <el-button
                          size="mini"
                          type="primary"
                          @click="reviewAndPass(scope.row.id)" v-if="scope.row.audit_state!='已删除'">审核通过</el-button>
                        <el-button
                          size="mini"
                          type="danger"
                          @click="deleteItem(scope.row)" v-if="scope.row.audit_state!='已删除'">删除</el-button>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="审核状态">
                      <template slot-scope="scope">
                        <span style="color:#000" v-if="scope.row.audit_state==='未审核'">未审核</span>
                        <span style="color:#67C23A" v-else-if="scope.row.audit_state==='审核通过'">审核通过</span>
                        <span style="color:#F56C6C" v-else-if="scope.row.audit_state==='已修改'">已修改</span>
                        <span style="color:#909399" v-else-if="scope.row.audit_state==='已删除'">已删除</span>
                        <span style="color:#E6A23C" v-else-if="scope.row.audit_state==='新增'">新增</span>
                        <span style="color:#C30000" v-else>存疑</span>
                      </template>
                    </el-table-column>
                    
                    
                  </el-table>
                  </div>


                  <div class="bottom-button-wrap clearfix">
                    <div class="fl">
                      <el-button type="primary" @click="toggleSelection(queryResult)" size="small">全选/反选</el-button>
                      <el-button type="primary" @click="passAll" size="small">审核通过</el-button>
                    </div>
                    <el-pagination
                      class="fr"
                      background
                      layout="prev, pager, next"
                      :total="resultTotal"
                      :current-page.sync="currentPage"
                      :page-size="20"
                      @current-change="changePage">
                    </el-pagination>
                  </div>
                </el-card>
              </el-main>
              <!-- content container end -->


              <el-footer>
                  <p class="gray">
                    @中国财富传媒集团 版权所有
                  </p>
              </el-footer>

            </el-container>
            <!-- 右侧主视图部分 END  -->
          </el-container>

        </el-container>
    </div>
</body>
    <script src="../../js/vue.js"></script>
    <script src="../../js/element.js"></script>
    <script src="../../js/axios.min.js"></script>
    <script src="../../js/jquery3.3.1.min.js"></script>
    <script src="../../js/md5.js"></script>
    <script src="../../js/common.js"></script>
  	<script>
  	  var app = new Vue({
  	      el: '#app',
          data(){
            return{
              queryUrl:'',
              maskShow:false,
              userName:localStorage.sys_userName,
              resultTotal:0,
              input_secuCode:'',
              input_startTime:'',
              input_endTime:'',
              queryResult:[],
              loading: false,
              currentPage:1,
              multipleSelection: [],
              selIdArr:[],
              selectOptions: [
                {
                  value: '全部',
                  label: '全部'
                }, {
                  value: '未审核',
                  label: '未审核'
                }, {
                  value: '审核通过',
                  label: '审核通过'
                }, {
                  value: '已修改',
                  label: '已修改'
                }, {
                  value: '新增',
                  label: '新增'
                },{
                  value: '已删除',
                  label: '已删除'
                } 
              ],
              selectedType:'全部',
              dealType:[],
              selectedDealType:''
            }
          },
          mounted:function(){
             this.initPage();
          },
          methods:{
              initPage:function(){
                
                  this.loading = true;
                  this.queryUrl = `https://goldeye.cfbond.com/cmsys/compliance_audit_list?audit_state=${this.selectedType}&session_id=${localStorage.sys_sessionId}`;
                  axios
                  .get(`https://goldeye.cfbond.com/cmsys/compliance_audit_list?session_id=${localStorage.sys_sessionId}`,
                    {
                      params:
                        {
                          audit_state:this.selectedType
                        }
                    })
                  .then((res)=>{
                    if(res.data.flag){
                      this.queryResult = res.data.data.data_list;
                      this.resultTotal = res.data.data.total_count;
                    }
                    this.loading = false;
                  });

                  // 获取扣分类型
                  axios
                  .get(`https://goldeye.cfbond.com/cmsys/deal_type?session_id=${localStorage.sys_sessionId}`)
                  .then((res)=>{
                    if(res.data.flag){
                      this.dealType = res.data.data;
                      this.dealType.unshift('全部');
                      this.selectedDealType = this.dealType[0];
                    }else{

                    }
                    
                  }); 
                               
              },
              queryData:function(sCode,sTime,eTime,state,pNum,dType){
                this.loading = true;
                this.queryUrl = `https://goldeye.cfbond.com/cmsys/compliance_audit_list?secu_code=${sCode}&start_time=${sTime}&end_time=${eTime}&audit_state=${state}&deal_type=${dType}&session_id=${localStorage.sys_sessionId}`;
                  axios
                  .get('https://goldeye.cfbond.com/cmsys/compliance_audit_list',
                    {
                      params:
                        {
                          secu_code:sCode,
                          start_time:sTime,
                          end_time:eTime,
                          audit_state:state,
                          page_num:pNum,
                          deal_type:dType,
                          session_id:localStorage.sys_sessionId
                        }
                    })
                  .then((res)=>{
                    if(res.data.flag){
                      this.queryResult = res.data.data.data_list;
                      this.resultTotal = res.data.data.total_count;
                    }else{
                      this.queryResult = [];
                      this.resultTotal = 0;
                      this.currentPage = 1;
                    }
                    this.loading = false;
                  });
              },
              changePage:function(cPage){

                this.queryData(this.input_secuCode,this.input_startTime,this.input_endTime,this.selectedType,cPage,this.selectedDealType);

              },
              userQuit:function(){
                this.$confirm('确认退出当前账户？', '确认退出', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(()=>{
                    Common.quit();
                  }).catch(()=>{
                    return false;
                  });
              },
              reviewAndPass:function(_id){
                axios
                  .get('https://goldeye.cfbond.com/cmsys/audit_pass',
                    {
                      params:
                        {
                          id:_id,
                          login_name:this.userName,
                          session_id:localStorage.sys_sessionId
                        }
                    })
                  .then((res)=>{
                    if(res.data.flag){//审核成功
                      this.$notify({
                        title: '成功',
                        message: '审核成功！',
                        type: 'success'
                      });
                      this.queryData(this.input_secuCode,this.input_startTime,this.input_endTime,this.selectedType,this.currentPage,this.selectedDealType);
                    }
                    
                  });
              },
              deleteItem(_obj) {
                _obj.audit_state="已删除";
                _obj.login_name = this.userName;
                axios
                  .get(`https://goldeye.cfbond.com/cmsys/compliance_audit_delete?session_id=${localStorage.sys_sessionId}`,
                    {
                      params:_obj
                    })
                  .then((res)=>{
                    if(res.data.flag){//审核成功
                      this.$notify({
                        title: '成功',
                        message: '删除成功！',
                        type: 'success'
                      });
                      this.queryData(this.input_secuCode,this.input_startTime,this.input_endTime,this.selectedType,this.currentPage,this.selectedDealType);
                    }
                    
                  });
              },
              toggleSelection(rows) {
                if (rows) {
                  rows.forEach(row => {
                    this.$refs.multipleTable.toggleRowSelection(row);
                  });
                } else {
                  this.$refs.multipleTable.clearSelection();
                }
                console.log(rows);
              },
              handleSelectionChange(val) {
                this.multipleSelection = val;
                function getId(obj){
                  return obj.id;
                }
                this.selIdArr = val.map(getId);
              },
              passAll:function(){//批量审核
                axios
                  .get('https://goldeye.cfbond.com/cmsys/audit_pass',
                    {
                      params:
                        {
                          id:this.selIdArr.join(','),
                          login_name:this.userName,
                          session_id:localStorage.sys_sessionId
                        }
                    })
                  .then((res)=>{
                    if(res.data.flag){//审核成功
                      this.$notify({
                        title: '成功',
                        message: '审核成功！',
                        type: 'success'
                      });
                      this.queryData(this.input_secuCode,this.input_startTime,this.input_endTime,this.selectedType,1,this.selectedDealType);
                      this.currentPage = 1;
                    }
                    
                  });
              },
              handleEdit:function(_id){
                window.location.href="./edit.html?itemId="+_id;
              },
              downloadData:function(){
                this.loading = true;
                axios
                .get(this.queryUrl+`&export=1&session_id=${localStorage.sys_sessionId}`)
                .then((res)=>{
                  if(res.data.flag){
                    window.open(res.data.download_url);
                    this.loading = false;
                  }else{
                      this.loading = false;
                      alert('请求出错')
                  }
                    
                })
                .catch((error)=>{
                  console.log(error);
                  alert('error');
                });
              }

          }
  	  });
  	</script>

</html>